Stop reporting transient backend 5xx errors from media location sync to Sentry#266
Conversation
…to Sentry The media location sync is non-critical background tracking, but it captured every ServerError (status >= 500) to Sentry. Transient backend infrastructure events such as Heroku 502s (returned by the router when no healthy dyno is available) are not actionable code bugs, so they surface as Sentry noise. Skip Sentry reporting for ServerError alongside the existing AbortError exclusion. Genuine failures (network errors, unexpected exceptions) are still reported. Fixes GUMROAD-MOBILE-WY
|
@claude review once |
Greptile SummaryThis PR stops
Confidence Score: 5/5Safe to merge — the change is narrowly scoped to Sentry reporting behavior for a non-critical fire-and-forget sync, with no effect on user-facing functionality or data integrity. The implementation correctly uses No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[updateMediaLocation called] --> B{accessToken present?}
B -- No --> C[return early]
B -- Yes --> D[requestAPI POST /mobile/media_locations]
D -- Success --> E[done]
D -- Throws --> F{catch block}
F --> G[console.warn]
G --> H{error type?}
H -- AbortError\ntimeout/poor connectivity --> I[skip Sentry]
H -- ServerError\ntransient 5xx from backend --> I
H -- Other error\nnetwork, unexpected --> J[Sentry.captureException]
Reviews (1): Last reviewed commit: "Stop reporting transient backend 5xx err..." | Re-trigger Greptile |
What
The media location sync (
updateMediaLocation) no longer reportsServerError(HTTP status ≥ 500) to Sentry. It now skips reporting forServerErroralongside the existingAbortErrorexclusion, while still reporting genuine failures such as network errors and unexpected exceptions.Why
Media location sync is non-critical background tracking that fires periodically while a buyer plays an audio/video file. The previous
catchblock reported every error to Sentry exceptAbortError, so transient backend 5xx responses showed up as Sentry issues.Root cause of the surfaced issue: the Gumroad backend returned
502 Bad GatewayforPOST /api/mobile/media_locations. No backend spans appeared in the trace, meaning Rails never processed the requests — the Heroku router returned 502 before reaching the app. Heroku routers return 502 when no healthy dyno is available (dyno crash, restart, or memory pressure). The window was ~50 minutes and affected only 2 users, consistent with a transient period of partial backend unavailability rather than a code bug.Because the sync still captured all
ServerErrors (status ≥ 500), this infrastructure event surfaced as an actionable issue in Sentry even though there is nothing to fix in the app. Transient 5xx responses from the backend are not actionable mobile-side bugs, so they are treated the same way as timeout-drivenAbortErrors: logged viaconsole.warnbut not sent to Sentry.useAPIRequestalready retriesServerErrors with exponential backoff, so genuine 5xx noise is reduced elsewhere; this change prevents the non-critical fire-and-forget sync from polluting Sentry with infrastructure blips.Before / After
This is a non-user-facing change (error-reporting behavior only). There is no UI change.
Failed to update media location: ServerError: Request failed: 502in Sentry.console.warnand not reported to Sentry. Network errors and other unexpected exceptions are still reported.Test Results
Added two tests to
tests/lib/media-location.test.ts:does not report transient ServerError (5xx) to Sentry(502 response fromfetch)does not report a directly thrown ServerError to SentryBoth tests fail when the fix is reverted, confirming they exercise the new behavior. Existing tests (including the
reports non-AbortError exceptions to Sentrycase) continue to pass, so genuine errors are still reported.npx tsc --noEmitpasses with no errors.🤖 AI disclosure: This PR was written by Claude Opus 4.6. Prompt: fix the GUMROAD-MOBILE-WY issue where the mobile app reported transient backend 502s from media location sync to Sentry, ensure the fix is fully working, add tests, and open a PR.
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Note
Low Risk
Observability-only change in a non-critical background sync path; real errors still go to Sentry.
Overview
Media location sync (
updateMediaLocation) still logs failures withconsole.warnand still swallows errors, but Sentry reporting now treatsServerError(HTTP ≥ 500) likeAbortError: transient backend 5xx (e.g. Heroku 502) are no longer sent to Sentry.Genuine failures (e.g. network errors and other non-
ServerErrorexceptions) continue to callSentry.captureException.Tests in
tests/lib/media-location.test.tscover both a 502fetchresponse and a directly thrownServerError, while the existing “reports non-AbortError” case still asserts real errors are reported.Reviewed by Cursor Bugbot for commit 8b7740a. Bugbot is set up for automated code reviews on this repo. Configure here.